package com.example.demo.entity;

import jakarta.persistence.Column;
import jakarta.persistence.MappedSuperclass;
import lombok.Getter;
import lombok.Setter;


import java.time.LocalDateTime;

/**
 * 哈希链基础实体类，所有需要防篡改的实体都应继承此类
 */
@MappedSuperclass
@Getter
@Setter
public abstract class HashChainEntity {

    /**
     * 当前记录的哈希值
     */
    @Column(name = "current_hash", nullable = false, length = 64)
    private String currentHash;

    /**
     * 上一次更新的哈希值，形成哈希链
     */
    @Column(name = "previous_hash", length = 64)
    private String previousHash;

    /**
     * 更新时间戳，防止重放攻击
     */
    @Column(name = "update_timestamp", nullable = false)
    private LocalDateTime updateTimestamp;
}
